
def p():
    p = 1
    t = 0
    for i in range(1, 11):
        p *= i
        t += p
        yield t

p = list(p())
p.reverse()
print p

def d(n):
    for i in p:
        yield n / i
        n = n % i

def n(i):
    q = list(d(i))
    q.reverse()
    # print q
    a = range(10)
    a.reverse()
    r = []
    for j in q:
        r.append(a[j])
        del a[j]
    r.reverse()
    return ''.join(map(str, r))
        
for i in range(10):
    print n(i)
    
print n(1000000)